package com.zlsy.secondtime.background;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhouliang
 * @date 2020/5/26 8:22
 * 在构造函数中新建线程
 */
public class MultiThreadsError6 {
    private Map<String, String> map;

    public MultiThreadsError6() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                map = new HashMap<>();
                map.put("a", "1");
                map.put("b", "2");
                map.put("c", "3");
                map.put("d", "4");
                map.put("e", "5");
            }
        }).start();
    }

    public Map<String, String> getStatus() {
        return map;
    }

    public static void main(String[] args) throws InterruptedException {
        MultiThreadsError6 multiThreadsError6 = new MultiThreadsError6();
        Thread.sleep(1000);
        System.out.println(multiThreadsError6.getStatus().get("a"));
    }
}
